package net.lab1024.sa.admin.module.workflow.dao;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.toolkit.Db;

import java.util.List;

/**
 * @author zmr
 * @version 1.0
 * @description
 * @date 2023/11/5 17:52
 */
public interface BaseMapperX<T> extends BaseMapper<T> {
    default void insertBatch(List<T> entities) {
        if (CollectionUtil.isNotEmpty(entities)) {
            int maxSize = 1000;
            List<List<T>> list = CollectionUtil.split(entities, maxSize);
            for (List<T> entity : list) {
                Db.saveBatch(entity, maxSize);
            }
        }
    }
}
